package com.acme.bankapp.domain.bank;

import com.acme.bankapp.exceptions.bank.NotEnoughFundsException;

public class SavingAccount extends AbstractAccount {
    public SavingAccount(double balance) {
        super(balance);
    }

    public void deposit(double amount) {
        this.balance += amount;
    }

    public void withdraw(double amount) throws NotEnoughFundsException {
        if (this.balance >= amount) {
            this.balance -= amount;
        } else {
            throw new NotEnoughFundsException(amount);
        }
    }

    public String toString() {
        return "SavingAccount: {" + super.toString() + "} ";
    }


    public double maximumAmountToWithdraw() {
        return this.balance;
    }
}
